import java.util.Scanner;

public class test5 {
    // 洛谷 U387710 整平地基计划
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int L = scan.nextInt();
        int W = scan.nextInt();
        int H = scan.nextInt();
        int m = scan.nextInt();
        int[][] arr = new int[L][W];

        for (int i = 0; i < L; i++) {
            for (int j = 0; j < W; j++) {
                arr[i][j] = scan.nextInt();
            }
        }
        int min = Integer.MAX_VALUE;
        int max = Integer.MIN_VALUE;
        int N = scan.nextInt();
        for (int i = 0; i < N; i++) {
            int sum = 0;
            int x1 = scan.nextInt();
            int y1 = scan.nextInt();
            int x2 = scan.nextInt();
            int y2 = scan.nextInt();
            x1 -= 1;y1 -= 1;x2 -= 1;y2 -= 1;

            for (int j = Math.min(x1,x2); j <= Math.max(x1, x2); j++) {
                for (int k = Math.min(y1,y2); k <= Math.max(y1, y2); k++) {

                    sum+=(H-arr[j][k])*m;
                }
            }
            min = sum<min?sum:min;
            max = sum>max?sum:max;
        }
        System.out.println(max);
        System.out.println(min);

    }
}
